Skip to content

feat(apple): Fix doctor issue with asdf#6062

Open
apburgess wants to merge 4 commits into
NativeScript:mainfrom
apburgess:fix-doctor-issue-with-asdf
Open

feat(apple): Fix doctor issue with asdf#6062
apburgess wants to merge 4 commits into
NativeScript:mainfrom
apburgess:fix-doctor-issue-with-asdf

Conversation

@apburgess

@apburgess apburgess commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Currently iOS builds can fail in the ns doctor stage when using asdf to specify the Ruby version; this happens because the CocoaPods checks performed by ns doctor are done in a new directory in /tmp which is missing the asdf configuration.

What is the new behavior?

If asdf is installed, the Ruby version specified for the project is added to a .tool-versions file in the CocoaPods test project folder; this stops the ns doctor command from failing and lets the build continue.

Implements #6061.

Note: I have run the existing tests; the only test that fails is 'skip when missing hook args' - but this also fails on a clean clone from the repo.

Summary by CodeRabbit

  • New Features

    • CocoaPods verification now detects and supports ASDF-managed Ruby setups by updating the relevant Ruby version configuration when found.
  • Bug Fixes

    • Improved diagnostic logging when CocoaPods commands fail, making troubleshooting output clearer.
    • Improved file-append behavior used during ASDF detection, returning success/failure reliably and reporting append errors.

apburgess added 3 commits June 4, 2026 19:22
If the user is using ASDF the 'doctor' command may fail at the Cocoapods stage as it will be using the global tool definitions instead of those specified by the project (if any).  This fixes the problem by generating a .tool-versions file with the correct settings in the temp directory used for the Cocoapods test.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

FileSystem gains a new synchronous appendFile method. SysInfo.isCocoaPodsWorkingCorrectly uses it to detect an ASDF-managed Ruby version via asdf current ruby and write a .tool-versions file into the temporary verification Xcode project directory. The pod install catch block now also logs the error before returning false.

Changes

ASDF Ruby Support in CocoaPods Verification

Layer / File(s) Summary
FileSystem.appendFile method
packages/doctor/src/wrappers/file-system.ts
Adds a synchronous appendFile(filePath, text): boolean method that resolves the path, appends text, returns true on success, and catches errors to log via console.error and return false. Also includes minor trailing-comma and punctuation cleanup on readJson and extractZip.
ASDF Ruby detection and .tool-versions injection
packages/doctor/src/sys-info.ts
After extracting the CocoaPods verification Xcode project, runs asdf current ruby, parses the detected Ruby version from stdout, and appends ruby <version> to .tool-versions in the project directory using appendFile. The pod install catch block now emits console.log("Pod command failed - <err>") before returning false.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • Support asdf in ns doctor #6061: This PR directly implements the feature requested in the issue — detecting ASDF Ruby in the CocoaPods verification flow and writing a .tool-versions file to ensure the correct Ruby version is used during pod install.

Poem

🐇 Hippity hop, I check your Ruby today,
With ASDF in hand, I find the right way.
A .tool-versions file, tucked in just right,
So CocoaPods pods install without a fight.
No more mysterious failures in the night! 🌙

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(apple): Fix doctor issue with asdf' accurately describes the main change: fixing a doctor validation issue specific to Apple/iOS builds related to asdf Ruby version management.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/doctor/src/sys-info.ts`:
- Around line 429-444: The asdf probe in the spawnFromEvent call at line 429
unconditionally fails if asdf is missing or misconfigured, causing healthy
setups to incorrectly report as broken. Additionally, using asdf list ruby may
match a non-active version instead of the currently active one. Add ignoreError:
true option to the spawnFromEvent call to prevent throwing, change the asdf
command from "list ruby" to "current ruby" to explicitly resolve the active
project Ruby version (which outputs the specific active version and
configuration source), and update the version matching logic if needed to work
with the output format of asdf current ruby.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a87b1a9-ab68-4240-9fb0-55de6c4fd509

📥 Commits

Reviewing files that changed from the base of the PR and between 86cb6a5 and 71e4e71.

📒 Files selected for processing (2)
  • packages/doctor/src/sys-info.ts
  • packages/doctor/src/wrappers/file-system.ts

Comment thread packages/doctor/src/sys-info.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/doctor/src/sys-info.ts (1)

447-450: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Terminate the appended .tool-versions entry with a newline.

At Line 449, appending ruby ${asdfVersion} without EOL can merge with existing content in .tool-versions and produce an invalid line when the file is pre-populated.

Suggested patch
 							const wroteASDFConfig = this.fileSystem.appendFile(
 								asdfConfigPath,
-								`ruby ${asdfVersion}`,
+								`ruby ${asdfVersion}${EOL}`,
 							);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/doctor/src/sys-info.ts` around lines 447 - 450, The appendFile call
in the asdfConfigPath section is appending `ruby ${asdfVersion}` without a
trailing newline character, which will cause the content to merge with existing
entries in the pre-populated `.tool-versions` file and create invalid lines. Add
a newline character (EOL or \n) at the end of the template string being appended
in the appendFile call for asdfConfigPath to ensure each entry is properly
terminated and on its own line.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@packages/doctor/src/sys-info.ts`:
- Around line 447-450: The appendFile call in the asdfConfigPath section is
appending `ruby ${asdfVersion}` without a trailing newline character, which will
cause the content to merge with existing entries in the pre-populated
`.tool-versions` file and create invalid lines. Add a newline character (EOL or
\n) at the end of the template string being appended in the appendFile call for
asdfConfigPath to ensure each entry is properly terminated and on its own line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 39b2db4a-fa53-4b30-b4f8-87d7f248a641

📥 Commits

Reviewing files that changed from the base of the PR and between 71e4e71 and b0f2371.

📒 Files selected for processing (1)
  • packages/doctor/src/sys-info.ts

["current", "ruby"],
"exit",
{ ignoreError: true },
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should set cwd since ns doctor can be run outside of project directories.

);
const wroteASDFConfig = this.fileSystem.appendFile(
asdfConfigPath,
`ruby ${asdfVersion}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`ruby ${asdfVersion}`,
`ruby ${asdfVersion}\n`

@NathanWalker NathanWalker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two nit's on version resolution being cwd explicit, a trailing newline for the tools etiquette (ensuring other appends don't mash together), and if possible to add a small unit test around asdf-present/asdf-absent behavior would be 💯 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants